home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 001-025 / disk_023 / ver30 / tty / intuition / console.c next >
C/C++ Source or Header  |  1992-05-06  |  2KB  |  103 lines

  1. /*
  2.  * These functions are taken directly from the
  3.  * console.device chapter in the Amiga V1.1
  4.  * ROM Kernel Manual.
  5.  */
  6. #include <exec/types.h>
  7. #include <exec/io.h>
  8. #include <devices/console.h>
  9. #include <libraries/dos.h>
  10. #include <intuition/intuition.h>
  11.  
  12. extern    LONG    OpenDevice();
  13. extern    LONG    DoIO();
  14. extern    LONG    SendIO();
  15.  
  16. /*
  17.  * Open a console device, given a read request
  18.  * and a write request message.
  19.  */
  20.  
  21. int OpenConsole(writerequest,readrequest,window)
  22. struct IOStdReq *writerequest;
  23. struct IOStdReq *readrequest;
  24. struct Window *window;
  25. {
  26.     LONG error; 
  27.     writerequest->io_Data = (APTR) window;
  28.     writerequest->io_Length = (ULONG) sizeof(*window);
  29.     error = OpenDevice("console.device", 0L, writerequest, 0L);
  30.  
  31.     /* clone required parts of the request */
  32.     readrequest->io_Device = writerequest->io_Device;
  33.     readrequest->io_Unit   = writerequest->io_Unit;
  34.     return((int) error);
  35. }
  36.  
  37. /*
  38.  * Output a single character    
  39.  * to a specified console
  40.  */ 
  41.  
  42. int ConPutChar(request,character)
  43. struct IOStdReq *request;
  44. char character;
  45. {
  46.     request->io_Command = CMD_WRITE;
  47.     request->io_Data = (APTR)&character;
  48.     request->io_Length = (ULONG)1;
  49.     DoIO(request);
  50.     /* caution: read comments in manual! */
  51.     return(0);
  52. }
  53.  
  54. /*
  55.  * Output a NULL-terminated string of
  56.  * characters to a console
  57.  */ 
  58.  
  59. int ConPutStr(request,string)
  60. struct IOStdReq *request;
  61. char *string;
  62. {
  63.     request->io_Command = CMD_WRITE;
  64.     request->io_Data = (APTR)string;
  65.     request->io_Length = (LONG)-1;
  66.     DoIO(request);
  67.     return(0);
  68. }
  69.  
  70. /*
  71.  * Write out a string of predetermined
  72.  * length to the console
  73.  */
  74.  
  75. int ConWrite(request,string,len)
  76. struct IOStdReq *request;
  77. char *string;
  78. int len;
  79. {
  80.     request->io_Command = CMD_WRITE;
  81.     request->io_Data = (APTR)string;
  82.     request->io_Length = (LONG)len;
  83.     DoIO(request);
  84.     return(0);
  85. }
  86.  
  87. /*
  88.  * Queue up a read request 
  89.  * to a console
  90.  */
  91.  
  92. int QueueRead(request,whereto)
  93. struct IOStdReq *request;
  94. char *whereto;
  95. {
  96.     request->io_Command = CMD_READ;
  97.     request->io_Data = (APTR)whereto;
  98.     request->io_Length = (LONG)1;
  99.     SendIO(request);
  100.     return(0);
  101. }
  102.  
  103.